package com.qf.blog.service.impl;

import com.qf.blog.core.dao.IBaseDao;
import com.qf.blog.core.service.BaseServiceImpl;
import com.qf.blog.dao.IInvitataionDao;

import com.qf.blog.entity.InvitataionEntity;
import com.qf.blog.mybatis.MyBatisUtils;
import com.qf.blog.mybatis.SqlSessionThreadLocal;
import com.qf.blog.service.IInvitataionService;
import com.qf.blog.vo.IndexDataVo;
import org.apache.ibatis.session.SqlSession;

import java.util.Date;
import java.util.List;

public class InvitataionServiceImpl extends BaseServiceImpl<InvitataionEntity> implements IInvitataionService {

//    private IInvitataionDao invitataionDao = new IInvitataionDaoImpl();

    @Override
    protected IBaseDao<InvitataionEntity> getBaseDao() {
        SqlSession sqlSession = SqlSessionThreadLocal.get();
        return sqlSession.getMapper(IInvitataionDao.class);
    }

    @Override
    public List<IndexDataVo> indexDataList() throws Exception {
        IInvitataionDao baseDao =(IInvitataionDao) getBaseDao();
        return baseDao.indexDataList();
    }

    @Override
    public boolean save(InvitataionEntity invitataionEntity) throws Exception {
        invitataionEntity.setStatus(1);
        invitataionEntity.setType(1);
        invitataionEntity.setCreateTime(new Date());
        invitataionEntity.setScore(0.1);
        invitataionEntity.setCommentCount(0);
        return super.save(invitataionEntity);
    }
}
